package com.forekonw.deom2;


import java.util.Scanner;

/**
 * while 循环
 */
public class LoopDemo2 {
    public static void main(String[] args) {
        //商品的名称
        String name = "";
        //价格
        double price = 0.0;
        //编号
        int goodsNo = 0;
        Scanner input = new Scanner(System.in);
        String answer = "y";
        double sum = 0;
        while ("y".equals(answer)){
            System.out.println("*****************");
            System.out.println("购物管理系统");
            System.out.println("请选择要购买的商品编号：");
            System.out.println("1.aaaa   2.bbbb   3.cccc");
            System.out.println("*****************");
            System.out.println("请输入商品的编号： ");
            goodsNo = input.nextInt();
            switch (goodsNo){
                case 1:
                    name = "aaaa";
                    price = 245.0;
                    sum += price;
                    break;
                case 2:
                    name = "bbbb";
                    price = 232.0;
                    sum += price;
                    break;
                case 3:
                    name = "cccc";
                    price = 221.0;
                    sum += price;
                    break;
                default:
                    price = 0;
                    System.out.println("无此类商品");
            }
            System.out.println("商品总金额 " + sum);
            System.out.println("商品的名称 "+ name +"商品的价格" + price);
            System.out.println("是否继续（y/n）");
            answer = input.next();
        }
        System.out.println("谢谢您的光临");
    }
}
